<?php
include("check.php");
include("check2.php");
include_once("../function.php");
include_once("../class/bonus_class.php");
include_once("../class/ulevel_class.php");
include_once("../class/member_class.php");
include_once("../class/system_class.php");
header("Content-Type: text/html;charset=utf-8");
session_start();
$us=GetMemberbyID($_SESSION['ID']);
$_bonus_cl=new bonus_class();
$_ulevel_cl=new ulevel_class();
if ($_POST['submit']){
    $member_cl=new member_class();
/*            if ($us['ulevel']<$_POST['uplv']){*/
                $chaer = getulevelss($_POST['uplv']);
                $cha=$chaer['lsk'];

          //      if($num>0){
                    $ulevelup['uid']=$_SESSION['ID'];
                    $ulevelup['nickname']=$us['nickname'];
                    $ulevelup['username']=$us['username'];
                    $ulevelup['ylevel']=$us['ulevel'];
                    $ulevelup['uplevel']=$_POST['uplv'];
                    $ulevelup['bdid']=$us['bdid'];
                    $ulevelup['bdname']=$us['bdname'];
                    $ulevelup['sid']=$us['id'];
                    $ulevelup['snickname']=$us['nickname'];
                    $ulevelup['susername']=$us['username'];
                    $ulevelup['udate']=now();
                    $ulevelup['issh']=0;
                    $ulevelup['cha']=$cha;
                    add_insert_cl('futou',$ulevelup);



                    /*         $member_cl->addArea($us['id'],$us['treeplace'],0);
                             $father=getMemberbyID($us['fatherid']);
                             $sql="select * from member where fatherid=".$us['fatherid']." order by lsk asc limit 0,1";
                             $query=mysql_query($sql);
                             $lsker=mysql_fetch_assoc($query);
                             $lsk=$lsker['lsk']>=$us['lsk']?$us['lsk']:$lsker['lsk'];
                             $_ilu=$_ulevel_cl->getulevelbyulevel($father['ulevel']);
                             $b2=$lsk*$_ilu['yl2']/100;
                             $_bonus_cl->b2bonus2($father['id'],$father['nickname'],$father['ppath'],$father['plevel'],$b2);

                             $_bonus_cl->bshengji();
                             $_bonus_cl->b3bonus($father['id'],$father['nickname'],$father['ppath'],$father['plevel'],$cha);*/
                    echo "<script language=javascript>alert('复投申请中.');window.location.href='?'</script>";
         /*       }else{
                    echo "<script language=javascript>alert('您的奖金币余额不足.');window.location.href='?'</script>";
                }*/
       /*     }else{
                echo "<script language=javascript>alert('申请级别错误,该会员的级别已经超过所申请级别.');window.location.href='?'</script>";
            }*/


}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="css/table.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <title>升级申请</title>
    <script language="javascript">
        <!--
        function checknickname(lx)
        {
            var iframe = document.getElementById("iframe");
            var user =  document.getElementById("nickname");
            iframe.src= "checknickname.php?lx="+lx+"&nickname="+user.value;
        }
        -->
    </script>
</head>
<body>
<iframe name="iframe" id="iframe" width="0" height="0" src="about:blank" style="display:none"></iframe>
<form name="form1" method="post" action="?" onSubmit="return CheckForm();">
    <table  width="100%" cellpadding="3" cellspacing="1" border="0" align="center" class="table1">
        <tr>
            <td align="right">奖金余额:</td>
            <td><?=$us['mey']?></td>
        </tr>
        <tr style="display: none">
            <td align="right">升级会员编号:</td>
            <td><input name="nickname" id="nickname" type="text">
                <input name="button4" type="button" class="button_blue" id="button4" onclick='checknickname(6);' value="验  证"><iframe name="iframe" id="iframe" width="0" height="0" src="about:blank" style="display:none"></iframe></td>
        </tr>
        <tr>
            <td width="46%" height="22" align="right">申请复投：</td>
            <td width="54%" align="left">
                <select name="uplv" id="uplv">
                    <?php
                    session_start();
                    $ulevel = $us['ulevel'];
                    $sql = "select * from ulevel where 1 ";
                    $result = mysql_query($sql);
                    while ($row = mysql_fetch_assoc($result)){?>
                        <option value='<?=$row['ulevel']?>'><?=$row['lvname']?></option>
                    <?php } ?>
                </select></td>
        </tr>
    </table>
    <table align="center" class="ziti">
        <tr>
            <td><input name="submit" id="submit" type="submit" class="button_green" value="申 请 复 投" onClick="javascript:return confirm('您确认申请复投吗？');"></td>
        </tr>
    </table>
    <br>
    <table width="100%" cellpadding="3" cellspacing="1" border="0" align="center" class="table1">
        <tr>
            <td height="20" colspan="8" align="center"> 申 请 记 录</td>
        </tr>
        <tr>

            <td align="center">复投会员编号</td>
            <td align="center">复投会员姓名</td>
            <td align="center">原级别</td>
            <td align="center">申请级别</td>
            <td align="center">补单金额</td>
            <td align="center">申请时间</td>
            <td align="center">操作人编号</td>
            <td align="center">操作人姓名</td>
            <td  align="center">审核状态</td>
        </tr>
        <?php
        $pagesize = 10; //设置每页记录数
        $sql = "SELECT * FROM `futou` WHERE uid=".$_SESSION['ID']." or sid=".$_SESSION['ID']." ";
        if($query = mysql_query($sql)){
            $sum = mysql_num_rows($query); //计算总记录数
        }else{
            $sum=0;
        }
        if($sum % $pagesize == 0) //计算总页数
            $total = (int)($sum/$pagesize);
        else
            $total = (int)($sum/$pagesize) + 1;
        if (isset($_GET['page'])) //获得页码
        {
            $p = (int)$_GET['page'];
        }
        else
        {
            $p = 1;
        }
        if ($p>$total){
            $p=$total;
        }
        $start = $pagesize * ($p - 1); //计算起始记录
        $sql = "SELECT * FROM `futou` WHERE uid=".$_SESSION['ID']." or sid=".$_SESSION['ID']." order by id desc limit ".$start.",".$pagesize;
        if($query = mysql_query($sql)){
            while ($row=mysql_fetch_array($query)){
                $yul=ulevel($row['ylevel']);
                $uul=ulevel($row['uplevel']);
                ?>
                <tr>

                    <td align="center"><?=$row['snickname']?></td>
                    <td align="center"><?=$row['susername']?></td>
                    <td align="center"><?=$yul['lvname']?></td>
                    <td align="center"><?=$uul['lvname']?></td>
                    <td align="center"><?=$row['cha']?></td>
                    <td align="center"><?=$row['udate']?></td>
                    <td align="center"><?=$row['nickname']?></td>
                    <td align="center"><?=$row['username']?></td>
                    <td align="center"><?php if ($row['issh']==1){?>通过审核<?php }elseif ($row['issh']==2){?>未通过审核<?php }else{?> <font color="#FF0000">未审核</font><?php }?></td>
                </tr>
                <?php
            }
        }
        ?>
    </table>
    <table width="100%" border="0" class="ziti">
        <tr>
            <td align="left">&nbsp;</td>
            <td align="right"><?php echo fenye($p,$pagesize,$sum,$total,$cx)?></td>
        </tr>
    </table>
</form>
</body>
</html>